package com.cyzy.server.dao;

import com.cyzy.pojo.entity.HuntCard;
import com.cyzy.pojo.entity.RecruitCard;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface RecruitCardDao {

    /**
     * tags数组到service层处理
     * @param recruitCard
     */
     void insert(RecruitCard recruitCard);

    /**
     * 返回招聘的列表帖子信息，找出displayed等于1的
     */
    @Select("select * from recruit_card where displayed = 1")
    List<RecruitCard> selectRecruitCard();

    /**
     * 根据用户id返回招聘的列表帖子信息
     */
    @Select("select * from recruit_card where publisher = #{id}")
    List<RecruitCard> selectRecruitCardByPublisher(Integer id);

    /**
     * 根据id返回招聘的列表帖子信息
     */
    @Select("select * from recruit_card where id = #{id}")
    RecruitCard selectRecruitCardById(Integer id);

    /**
     * 查询招募帖子表的数据行数
     */
    @Select("select count(*) from recruit_card")
    Integer selectRecruitCardCounts();

    /**
     * 修改求职帖子的信息
     */
    void update(RecruitCard recruitCard);

    /**
     * 取消展示状态(伪删除帖子)
     */
    @Update("update recruit_card set displayed = 0 where id = #{id}")
    void fakeDeleteRecruitCard(Integer id);

    /**
     * 恢复展示状态
     */
    @Update("update recruit_card set displayed = 1 where id = #{id}")
    void recoverRecruitCard(Integer id);

    /**
     * 更新招募帖子的状态
     */
    @Update("update recruit_card set status = #{status} where id = #{id}")
    void updateRecruitCardStatus(String status,Integer id);

    /**
     * 根据用户id查询其发布的贴子数
     */
    @Select("select COUNT(*) from recruit_card where publisher = #{id}")
    int getRecruitCount(int id);


}
